//////////////////////////////////////////////////////////////////////////
// Author:		Dan Polak
// Date:		3/25/2011
// Last Mod:	N/A
//
// File:		Object Manager.h
//
// Purpose:		Manage all objects in the game. This will handle the creation
//				of and deletion of these objects. In addition, it will call
//				the update, and render functions for these objects to be used
//				throughout the game. This will store both rendered and non-
//				rendered objects such as collision bounds.
//////////////////////////////////////////////////////////////////////////

#ifndef OBJ_MANAGER_H
#define OBJ_MANAGER_H

#include <vector>

struct AABB;
struct Plane;
struct Cylinder;
class CEnemies;
class CBullets;
class CGame;
class CLevelManager;

class COBJManager
{
private:
	//Instance
	static COBJManager* m_pInstance;
	
	//Map Loader
	friend CLevelManager;
	CLevelManager* m_pLevel;

	//Other friends
	friend CEnemies;
	friend CBullets;
	friend CGame;

	//Helper Functions
	void CheckCollisions();
	void WallSlidePlaneDetection(vec3f vStartPos, vec3f vEndPos, AABB* aabb);
	void HandleWallSlide(Plane p, vec3f vStart, vec3f vEnd);

protected:
	std::vector<AABB*>			m_vAABBs;
	std::vector<Cylinder*>		m_vCylinders;
	std::vector<CEnemies*>		m_vEnemies;
	std::vector<CBullets*>		m_vBullets;
	std::vector<CBullets*>		m_vEnemyBullets;

	//Debug only
	void GetAColor(unsigned int i);

public:
	static COBJManager* GetInstance(void);

	void Update(float fDeltaTime);

	void Render(void);

	void CreateObjects();

	void DestroyObjects();

};

#endif